﻿using System;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using Serilog.AspNetCore;
using Serilog.Formatting.Json;

namespace _07_Serilog_集中化_结构化日志
{
    internal class Program
    {
        static void Main(string[] args)
        {
            ServiceCollection services = new ServiceCollection();
            services.AddLogging(e =>
            {
                Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .Enrich.FromLogContext()
                .WriteTo.Console(new JsonFormatter())
                .CreateLogger();
                
                e.AddSerilog();

            });
            services.AddScoped<test1>();

            using (var sp = services.BuildServiceProvider())
            {
                var t = sp.GetRequiredService<test1>();
                t.wLog();
            }
        }
    }
}
class User
{
    public string Name { get; set; }
    public string Email { get; set; }
}
